import React, { useContext, useEffect, useState } from 'react';
import {
    ActivityIndicator,
    Alert,
    DeviceEventEmitter, Dimensions,
    ImageBackground,
    RefreshControl,
    TextInput,
    TouchableOpacity,
    View
} from 'react-native';
import { Icon, Image, ListItem, Text } from 'react-native-elements';
import LocaleContext from '../libs/locale';
import WalletContext from '../libs/wallet';
import AsyncStorage from '@react-native-async-storage/async-storage';

import susdtlogo from '../assets/susdt.png';
import sETHlogo from '../assets/1.png';
import otherTokenLogo from '../assets/aboutlogo.png';

import {constansts} from "./../libs/constansts";
import { ScrollView } from 'react-native';
import {useFocusEffect} from "@react-navigation/native";
import {getRandomUrl, getTxInfo, getTxs, getTxs_Ip, SaveMyID} from "../libs/nodes";
import {formartMoney, sleep, timeFormat} from "../libs/helpers";
import scan from "../assets/Assets/scan.png";
import {bytes2Hex, hex2Bytes, hex2Bytes_Random, keyPairFromSeed} from "../libs/keyPair";
import {convertKeyPair, convertPublicKey} from "../libs/ed2curve";
import Cp from "crypto-js";


const {width,height,scale} = Dimensions.get("window");


const ChatList = ({navigation,route}:any) =>{
    const locale:any = useContext(LocaleContext);
    const wallet: any = useContext(WalletContext);
    const [ChatList,setChatList]:any = useState([]);
    const [showWaiting,setShowWaiting] = useState(false)
    const [progressLength,setProgressLength] = useState("0")
    const [TipInfo,setTipInfo] = useState("")

    const title =  locale._("MeChat_ChatList_Title");
    let FirstLogin = true;
    let ChatListNow:any = [];
    //获取存储的数据并写入列表
    const getStore = async () => {
        // await AsyncStorage.setItem("@chatList","[]") ;
        let SaveList = await AsyncStorage.getItem("@chatList") || "[]";
        // console.log("主页数据："+SaveList)
        var resList: any = JSON.parse(SaveList) || [];
        ChatListNow = resList;
        let timetemp = new Date().getTime()
        setChatList(resList);
        console.log("渲染数组Finis-List："+(new Date().getTime() - timetemp))
        return resList;
    }

    //获取最近60笔交易
    // const getRecentTran = async () => {
    //     var info: any = [];
    //     //获取60笔交易的信息
    //     for (let i = 0; i < 10; i++) {
    //         let res = await getTxs(wallet.address, i);
    //         info.splice(12 * (i + 1) - 1, 0, ...res)
    //         if (info.length !== (i + 1) * 12) {
    //             break;
    //         }
    //     }
    //     setInfoList([...info])
    //     return info;
    // }

    //将得到的60笔交易信息进行分类处理得到根据地址分类的数据
    const solveTran = async (info:any) => {

        const doSetpL = async (i: any, info: any) => {
            await sleep(1)
            let pL = 0.8 + (i / info.length) * 0.1;
            let pLM = Math.floor(pL * 100) / 100;
            console.log("pL=" + pLM)
            setProgressLength(pLM.toString());
            console.log(progressLength)
        }

        //信息解密
        const decryptedInformation = (item:any) =>{
            try {
                let nacl = require("tweetnacl");
                //获取自己的公钥
                let getPublicKeyByte = () => {
                    let keyPair: any = keyPairFromSeed(wallet.seed);
                    let publicKey = keyPair.publicKey;
                    return convertPublicKey(publicKey);
                }
                //将字符串转成字节数组
                let decodeUTF8 = function (s: string) {
                    var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
                    for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
                    return b;
                };
                //将字节数组转成字符串
                let encodeUTF8 = function (arr: any) {
                    var i, s = [];
                    for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
                    return decodeURIComponent(escape(s.join('')));
                };
                //设置随机nonce值
                nacl.setPRNG((x: any, n: any) => {
                    x = hex2Bytes_Random(n);
                })
                // 随机nonce值
                let nonceRandom = nacl.randomBytes(24);
                let DHKeyMy:any = convertKeyPair(keyPairFromSeed(wallet.seed));

                //获取他的公钥
                let data = JSON.parse(item.remarks);
                // let data :any = null;
                // console.log(`得到的数据data:${item.remarks}`)
                let pubHex:string;
                if(item.addressIn === wallet.address) //我发的消息，我将他的公钥用自己的私钥加密保存起来后面用
                {
                    var key  = Cp.enc.Utf8.parse(wallet.seed);
                    var decrypt = Cp.AES.decrypt(data.publicKey, key, {mode:Cp.mode.ECB,padding: Cp.pad.Pkcs7});
                    pubHex = Cp.enc.Utf8.stringify(decrypt).toString();
                    // console.log(`解析出来的数据：${pubHex}`)
                }
                else//他发的消息，我直接从签名那边获取他的公钥后面用
                {
                    let signRes = Cp.enc.Base64.parse(item.sign);
                    pubHex = signRes.toString().slice(-64);
                }
                let pub = hex2Bytes(pubHex);
                // console.log(`解析出来的公钥数组：${pub}`)
                let pubED = convertPublicKey(pub);
                // console.log(`解析出来的解密公钥数组：${pubED}`)
                var decryptedMessage = nacl.box.open(hex2Bytes(data.msg), nonceRandom,pubED, DHKeyMy.secretKey);
                let res = encodeUTF8(decryptedMessage)
                // console.log(`最终解析出来的数据：${res}`)
                return res;
            }catch (e) {
                // console.log(e)
                return false;
            }

        }

        //获取公钥
        const getPubKey = (item:any) => {
            let data = JSON.parse(item.remarks);
            let pubHex:string;
            if(item.addressIn === wallet.address) //我发的消息，我将他的公钥用自己的私钥加密保存起来后面用
            {
                var key  = Cp.enc.Utf8.parse(wallet.seed);
                var decrypt = Cp.AES.decrypt(data.publicKey, key, {mode:Cp.mode.ECB,padding: Cp.pad.Pkcs7});
                pubHex = Cp.enc.Utf8.stringify(decrypt).toString();
                // console.log(`解析出来的数据：${pubHex}`)
            }
            else//他发的消息，我直接从签名那边获取他的公钥后面用
            {
                let signRes = Cp.enc.Base64.parse(item.sign);
                pubHex = signRes.toString().slice(-64);
            }
            return pubHex;
        }

        var ChatListTemp = [];
        console.log()
        console.log("info.length="+info.length)
        for (let i = 0; i < info.length; i++)
        {
            await sleep(0)
            console.log(`i=${i}`)
            await doSetpL(i,info);
            try {
                // console.log(typeof info[i].remarks)
                let remarks = JSON.parse(info[i].remarks);
                if (remarks.type !== "chat") {
                    // console.log(`try里面的continue`)

                    continue;
                }
                let remarksMsgStr = decryptedInformation(info[i]);
                if(!remarksMsgStr)
                {

                    continue;
                }
                // console.log(`remarksMsgStr:${remarksMsgStr}`)
                info[i].pubkey = getPubKey(info[i]);
                info[i].remarks = JSON.stringify({type:"chat",msg:remarksMsgStr,desc:""});
            }
            catch (e) {
                // console.log(`catch里面的continue`)

                continue;
            }
            // console.log(`这个显示了就不该显示continue了`);

            //本来为空就应该直接放数据进去
            if (ChatListTemp.length === 0) {
                let remarks = JSON.parse(info[i].remarks);
                let addressOut = (info[i].addressIn === wallet.address ? info[i].addressOut : info[i].addressIn);

                ChatListTemp.push({
                    pubkey:info[i].pubkey,
                    desc: addressOut.slice(0,5)+"..."+addressOut.slice(-5),
                    addressOut: addressOut,
                    info: [{sender: info[i].addressIn, msg: remarks.msg, timeStamp: info[i].timestamp}]
                });

                continue;
            }
            //有数据考虑是添加数据还是新的朋友

            for (let ii = 0; ii < ChatListTemp.length; ii++) {
                await sleep(0)
                let remarks = JSON.parse(info[i].remarks);
                if (info[i].addressOut === ChatListTemp[ii].addressOut || info[i].addressIn === ChatListTemp[ii].addressOut) {
                    //后面添加信息
                    ChatListTemp[ii].info.splice(0, 0, {
                        sender: info[i].addressIn,
                        msg: remarks.msg,
                        timeStamp: info[i].timestamp
                    });

                    break;
                }
                //如果是新的朋友
                if (ii === (ChatListTemp.length - 1)) {
                    let addressOut = (info[i].addressIn === wallet.address ? info[i].addressOut : info[i].addressIn);
                    ChatListTemp.push({
                        pubkey:info[i].pubkey,
                        desc: addressOut.slice(0,5)+"..."+addressOut.slice(-5),
                        addressOut: addressOut,
                        info: [{sender: info[i].addressIn, msg: remarks.msg, timeStamp: info[i].timestamp}]
                    });

                    break;
                }

            }


        }
        return ChatListTemp;
    }

    //设置名称
    const setListName = async (List: any) => {
        for (let i = 0; i < List.length; i++) {
            let addressOut = List[i].addressOut;
            console.log(addressOut)
            let res = await SaveMyID(addressOut, "", "1");
            let Name = res.dict.nickname || addressOut.slice(0,5)+"..."+addressOut.slice(-5);
            List[i].desc = Name;
        }
        return List;
    }

    //将分类好的数据写入数据库和渲染
    const saveMsg = async (ChatListTemp: any) => {

        const doSetpL = async (i: any, info: any) => {
            await sleep(1)
            let pL = 0.9 + (i / info.length) * 0.1;
            let pLM = Math.floor(pL * 100) / 100;
            console.log("pL=" + pLM)
            setProgressLength(pLM.toString());
            console.log(progressLength)
        }

        // console.log(`resList:${JSON.stringify(resList)}`)
        // console.log(`ChatListTemp:${JSON.stringify(ChatListTemp)}`)
        for (let i = 0; i < ChatListTemp.length; i++) {
            await doSetpL(i, ChatListTemp);
            await sleep(0)
            //console.log(`i=${i}`)
            //数据库数据为空直接添加
            if (ChatListNow.length === 0) {
                ChatListNow.push(ChatListTemp[i]);
                for(let iii = 0 ; iii < ChatListTemp[i].info.length ; iii++ )
                {
                    // console.log(`出现错误的数据${i}   ${iii}   ${JSON.stringify(ChatListTemp[i].info[iii])}`)
                    if (ChatListTemp[i].info[iii].sender !== wallet.address) {
                        ChatListNow[0].unread = (ChatListNow[0].unread || 0) + 1;
                    }
                }
                continue;
            }
            for (let ii = 0; ii < ChatListNow.length; ii++) {
                await sleep(0)
                //console.log(`ii=${ii}`)
                //如果好友位里面已经有了，就可以比较数据进行添加了
                if (ChatListTemp[i].addressOut === ChatListNow[ii].addressOut) {
                    //添加数据
                    for (let iii = 0; iii < ChatListTemp[i].info.length; iii++) {
                        //console.log(`交易列表的时间戳${parseInt(ChatListTemp[i].info[iii].timeStamp)}`)

                        for (let j = 0; j < ChatListNow[ii].info.length; j++) {
                            await sleep(0)
                            if(parseInt(ChatListTemp[i].info[iii].timeStamp) < ChatListNow[ii].info[0].timeStamp && j===0)
                            {
                                ChatListNow[ii].show = true;
                                if (ChatListTemp[i].info[iii].sender !== wallet.address) {
                                    ChatListNow[ii].unread = (ChatListNow[ii].unread || 0) + 1;
                                }
                                ChatListNow[ii].info.splice(0, 0, ChatListTemp[i].info[iii]);
                                break;
                            }
                            if(parseInt(ChatListTemp[i].info[iii].timeStamp) == ChatListNow[ii].info[j].timeStamp)
                            {
                                ChatListNow[ii].info[j].showFalse = false ;
                                ChatListNow[ii].info[j].showTraning = false ;
                                ChatListNow[ii].info[j].hash = false ;
                            }
                            //console.log(`ChatListTemp[i].info[iii]${JSON.stringify(ChatListTemp[i].info[iii])}`)
                            if (parseInt(ChatListTemp[i].info[iii].timeStamp) > ChatListNow[ii].info[j].timeStamp && (j == (ChatListNow[ii].info.length - 1) || parseInt(ChatListTemp[i].info[iii].timeStamp) < ChatListNow[ii].info[j + 1].timeStamp)) {
                                ChatListNow[ii].show = true;
                                if (ChatListTemp[i].info[iii].sender !== wallet.address) {
                                    ChatListNow[ii].unread = (ChatListNow[ii].unread || 0) + 1;
                                }
                                ChatListNow[ii].info.splice(j + 1, 0, ChatListTemp[i].info[iii]);
                                break;
                            }
                        }
                    }
                    break;
                }
                //新的好友位
                if (ii === (ChatListNow.length - 1)) {
                    ChatListNow.splice(0, 0, ChatListTemp[i]);
                    // console.log(`新朋友添加未读${i}     ${JSON.stringify(ChatListTemp[i].info.length)}     ${JSON.stringify(ChatListTemp[i].info)}`)
                    for(let iii = 0 ; iii < ChatListTemp[i].info.length ; iii++ )
                    {
                        // console.log(`出现错误的数据${i}   ${iii}   ${JSON.stringify(ChatListTemp[i].info[iii])}`)
                        if (ChatListTemp[i].info[iii].sender !== wallet.address) {
                            ChatListNow[0].unread = (ChatListNow[0].unread || 0) + 1;
                        }
                    }
                    break;
                }
            }

            if(showWaiting)
            {
                let pL = 0.9+(i/ChatListTemp.length)*0.1;
                setProgressLength( (Math.floor(pL * 100) / 100).toString())
            }

        }

        for (let i = 0; i < ChatListNow.length; i++) {
            for(let j = 0 ; j < ChatListNow[i].info.length ; j++)
            {
                let data = ChatListNow[i].info[j];
                if(data.hash && ((new Date().getTime())-data.timeStamp)>(2*60*1000) && data.display!==false)
                {
                    if(data.falseTime == 0)
                    {
                        data.showFalse = true ;
                        data.showTraning = false ;
                        data.hash = false ;
                    }
                    data.falseTime -= 1;

                }
                ChatListNow[i].info[j] = data;
            }
        }
        ChatListNow = await setListName(ChatListNow);
        await AsyncStorage.setItem("@chatList", JSON.stringify(ChatListNow));
        // console.log(JSON.stringify(ChatListNow))
        console.log(`存储完毕开始渲染`)
        setProgressLength("1");
        let timetemp = new Date().getTime()
        setChatList([...ChatListNow]);
        console.log("渲染数组Finis-List："+(new Date().getTime() - timetemp))
        return ChatListNow;
    }

    //设置标题
    const setTitle = (titleStr:string) => {
        navigation.setOptions({title: titleStr})
    }

    //初始化数据
    useEffect(()=>{
        setTitle(title);
        //获取存储的列表，先显示出来
        getStore().then(
            async () => {
                await workHistory_First();
            }
        );
        },[])

    //初始化扫码按钮
    useEffect(() => {
        navigation.setOptions({
            headerRight: () => (
                <TouchableOpacity style={{
                    width: 30,
                    height: 35,
                    marginRight: 20,
                    alignItems: "center",
                    justifyContent: "center"
                }}
                  onPress={ () => {
                        navigation.navigate("ChatQRscan")
                  }}
                >
                    <ImageBackground source={scan} style={{width: 25, height: 25}}/>
                </TouchableOpacity>
            ),
        });
    },[])

    //定时器获取数据
    useFocusEffect(
        React.useCallback(() => {

            getStore()
            const t = setInterval(workHistoryWithoutGif,15*1000)
            return ()=>{
                clearInterval(t);
            }
        }, [])
    );

    const getHistory_Random = async () => {
        var info: any = [];
        //获取最多200笔交易的信息
        let LastTime: number;
        try {
            let LastStr = await AsyncStorage.getItem("LastGetTime")  ;
            if(!LastStr)
            {
                LastStr = "1";
            }
            LastTime = parseInt( LastStr ,10) - 1 ;
            if(new Date().getTime() - LastTime > constansts.chatSearchMaxTime)
            {
                LastTime = new Date().getTime() - constansts.chatSearchMaxTime;
            }
        }catch (e) {
            console.log("直接catch了")
            LastTime = new Date().getTime() - constansts.chatSearchMaxTime;
        }
        console.log(`LastTime_Random:${LastTime}`)
        for (let i = 0; i < Math.floor(constansts.chatSearchMaxLength/12); i++) {
            let res = [];
            try{
                res = await getTxs(wallet.address, i);
            }catch (e) {

            }
            info.splice(12 * (i + 1) - 1, 0, ...res);

            let nowGetTime = 0;
            try {
                nowGetTime = parseInt(res[res.length - 1].timestamp);
            }catch (e) {

            }
            if (info.length !== (i + 1) * 12 || nowGetTime <= LastTime) {
                break;
            }
        }
        await AsyncStorage.setItem("LastGetTime",info.length>0?info[0].timestamp.toString():LastTime.toString());
        return info;
    }

    const getHistory_First = async () => {
        var info: any = [];
        //获取最多200笔或者1星期之内的交易的信息
        let LastTime: number;
        setProgressLength("0" );
        setTipInfo(locale._("MeChat_ChatList_Tip1"))
        try {
            let LastStr = await AsyncStorage.getItem("LastGetTime") || "1" ;
            console.log(`LastStr:${LastStr}`)
            LastTime = parseInt( LastStr ) - 1 ;
            if(new Date().getTime() - LastTime > constansts.chatSearchMaxTime)
            {
                LastTime = new Date().getTime() - constansts.chatSearchMaxTime ;
            }
        }catch (e) {
            console.log("直接catch了")
            LastTime = new Date().getTime() - constansts.chatSearchMaxTime;
        }
        console.log(`LastTime:${LastTime}`)
        for (let i = 0; i < Math.floor(constansts.chatSearchMaxLength/12); i++) {
            let res = [];
            try{
                res = await getTxs(wallet.address, i);
            }catch (e) {

            }
            info.splice(12 * (i + 1) - 1, 0, ...res);
            let pL = parseFloat(progressLength);
            try {
                pL = (constansts.chatSearchMaxTime - (res[res.length - 1].timestamp - LastTime)) / constansts.chatSearchMaxTime*0.8;
            }catch (e) {

            }
            setProgressLength(pL>0.8?"0.8":pL.toString() );
            let nowGetTime = 0;
            try {
                nowGetTime = parseInt(res[res.length - 1].timestamp);
            }catch (e) {
            }
            if (info.length !== (i + 1) * 12 || nowGetTime <= LastTime) {
                setProgressLength("0.8");
                setTipInfo(locale._("MeChat_ChatList_Tip2"))
                break;
            }
        }
        await AsyncStorage.setItem("LastGetTime",info.length>0?info[0].timestamp.toString():LastTime.toString());
        return info;
    }

    const workHistory_First = async () => {
        // console.log("开始获取所有历史记录")
        setShowWaiting(true);

        //获取最新交易
        var info = await getHistory_First();

        //将信息分类写入
        var ChatListTemp = await solveTran(info);

        //将好友列表比较并且保存
        await saveMsg(ChatListTemp);


        setShowWaiting(false)
        setProgressLength("0");
    }

    const workHistoryWithoutGif = async () => {
        console.log(`FirstChat:${0}`)
        console.log("开始获取所有历史记录")

        //获取最新交易
        var info = await getHistory_Random();

        //将信息分类写入
        var ChatListTemp = await solveTran(info);

        //将好友列表比较并且保存
        await saveMsg(ChatListTemp);
    }

    return (
        <View>
            {
                showWaiting?
                    <View style={{width:width,height:height,backgroundColor:"#F5F5F5"}}>
                        <ActivityIndicator
                            animating={true}
                            color={'lightblue'}
                            size={50}
                            style={{width:width,backgroundColor:"#FFFAFA69",marginTop:0.3*height}}
                        />
                        <Text style={{alignSelf:"center",marginTop:20}}>{formartMoney((parseFloat(progressLength)*100).toString(),2)}% {TipInfo}</Text>
                        <View style={{backgroundColor:"#DCDCDC",width:width*0.8,height:20,borderRadius:10,marginTop:25,alignSelf:"center"}}/>
                        <View style={{backgroundColor:"#69BDF4",width:width*0.8*parseFloat(progressLength)>20?width*0.8*parseFloat(progressLength):20,height:20,borderRadius:10,marginTop:-20,alignSelf:"flex-start",marginLeft:width*0.1}}/>
                    </View>:null
            }
            <ScrollView
                style={{height:height*0.9}}
                refreshControl={
                <RefreshControl refreshing={false} onRefresh={() => {workHistoryWithoutGif()}} collapsable={true}/>
            }>
                <View >
                    {
                        ChatList.length
                            ?
                            ChatList.map((tx: any,index:any) => (
                                tx.show!==false?
                                        <ListItem bottomDivider
                                                  style={{shadowOpacity:1}}
                                                  underlayColor="rgba(34, 26, 38, 0.1)"
                                                  onPress={async ()=>
                                                  {
                                                      console.log("ONPRESS")
                                                      // console.log(JSON.stringify(tx));
                                                      let tempList = await getStore();
                                                      tempList[index].unread = 0;
                                                      console.log(JSON.stringify(tempList))
                                                      await AsyncStorage.setItem("@chatList", JSON.stringify(tempList));
                                                      let timetemp = new Date().getTime()
                                                      setChatList([...tempList]);
                                                      console.log("渲染数组Finis-List："+(new Date().getTime() - timetemp))
                                                      navigation.push("ChatView",{ToAddress:tx.addressOut,desc:tx.desc || (tx.addressOut.slice(0,5)+"..."+tx.addressOut.slice(-5)),pubkey:tx.pubkey,info:tx.info || []})
                                                  }}
                                                  onLongPress={async () => {
                                                      const delChat = async () => {
                                                          let tempList = [...ChatList];
                                                          tempList[index].show = false;
                                                          await AsyncStorage.setItem("@chatList", JSON.stringify(tempList));
                                                          setChatList([...tempList]);
                                                      }
                                                      Alert.alert('', `是否删除与 ${tx.desc || (tx.addressOut.slice(0,5)+"..."+tx.addressOut.slice(-5))} 的对话`, [{
                                                          text: locale?._('cancel'),
                                                          onPress: () => console.log("Cancel Pressed"),
                                                          style: "cancel"
                                                      }, {
                                                          text: locale?._('ok'),
                                                          onPress: async () => {
                                                              await delChat();
                                                          }
                                                      }]);

                                                  }}
                                                  activeOpacity={0.5} key={index}>
                                            <ImageBackground source={tx.logo?{uri:tx.logo.uri}:otherTokenLogo} style={{ width: 38, height: 38 }} />
                                            <ListItem.Content style={{backgroundColor:"white"}}>
                                                <ListItem.Title style={{fontSize:width/360*15}} numberOfLines={1}>{tx.desc}</ListItem.Title>
                                                <ListItem.Subtitle style={{height:15,fontSize:width/360*10}} numberOfLines={1}>
                                                    <Text numberOfLines={1} style={{color:'grey'}}>
                                                        {(tx.info.length - 1)>=0?(tx.info[(tx.info.length - 1)].msg):"" }
                                                    </Text>
                                                </ListItem.Subtitle>

                                            </ListItem.Content>
                                            <View style={{backgroundColor:"white",width:width/360*80,flexDirection:"column",alignItems:"flex-end",marginRight:width/360*0}}>
                                                <View style={{flexDirection:"column",width:width/360*80,justifyContent:"flex-end"}}>
                                                    <Text style={{fontSize:width/360*12,color:"grey",alignSelf:"flex-end"}}>
                                                        {/*{console.log("有多少少聊天记录？"+JSON.stringify(tx.info))}*/}
                                                        {(tx.info.length - 1)>=0?(timeFormat((tx.info[(tx.info.length - 1)].timeStamp)).slice(5,16)):"" }
                                                    </Text>
                                                </View>
                                                <View style={{flexDirection:"column",width:width/360*50,justifyContent:"center"}}>
                                                    {
                                                        tx.unread?
                                                            <Text style={{marginTop:5,fontSize:width/360*12,color:"white",alignSelf:"flex-end",backgroundColor:"lightgrey",paddingLeft:12,paddingRight:12,borderRadius:12}}>
                                                                {tx.unread || ""}
                                                            </Text>
                                                            :
                                                            <Text style={{marginTop:5,fontSize:width/360*12,color:"white",alignSelf:"flex-end"}}>
                                                                {""}
                                                            </Text>
                                                    }

                                                </View>
                                            </View>
                                            {/*<Icon type='feather' name='arrow-right' color='#7259E0FF' size={24} />*/}
                                        </ListItem>
                                    :null
                            ))
                            :
                            <View style={{ flex: 1, justifyContent: 'center' }}>
                                <Text style={{
                                    marginTop: '100%',
                                    fontSize: 20,
                                    textAlign: 'center',
                                    color: 'grey'
                                }}>{locale?._('noContent')}</Text>
                            </View>
                    }
                </View>
            </ScrollView>

        </View>
    );

};
export default ChatList;
